package o;

import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

public final class vm implements vg {
    private volatile Map<String, String> ˏ;
    private final Map<String, List<vd>> ॱ;

    public static final class a {
        private static final Map<String, List<vd>> ˊ;
        private static final String ˋ = ˎ();
        private Map<String, List<vd>> ˎ = ˊ;
        private boolean ˏ = true;
        private boolean ॱ = true;

        static {
            Map hashMap = new HashMap(2);
            if (!TextUtils.isEmpty(ˋ)) {
                hashMap.put("User-Agent", Collections.singletonList(new d(ˋ)));
            }
            ˊ = Collections.unmodifiableMap(hashMap);
        }

        public vm ˋ() {
            this.ˏ = true;
            return new vm(this.ˎ);
        }

        @VisibleForTesting
        static String ˎ() {
            String property = System.getProperty("http.agent");
            if (TextUtils.isEmpty(property)) {
                return property;
            }
            int length = property.length();
            StringBuilder stringBuilder = new StringBuilder(property.length());
            for (int i = 0; i < length; i++) {
                char charAt = property.charAt(i);
                if ((charAt > '\u001f' || charAt == '\t') && charAt < '') {
                    stringBuilder.append(charAt);
                } else {
                    stringBuilder.append('?');
                }
            }
            return stringBuilder.toString();
        }
    }

    static final class d implements vd {
        @NonNull
        private final String ˏ;

        d(@NonNull String str) {
            this.ˏ = str;
        }

        public String ˏ() {
            return this.ˏ;
        }

        public String toString() {
            return "StringHeaderFactory{value='" + this.ˏ + '\'' + '}';
        }

        public boolean equals(Object obj) {
            if (!(obj instanceof d)) {
                return false;
            }
            return this.ˏ.equals(((d) obj).ˏ);
        }

        public int hashCode() {
            return this.ˏ.hashCode();
        }
    }

    vm(Map<String, List<vd>> map) {
        this.ॱ = Collections.unmodifiableMap(map);
    }

    public Map<String, String> ˏ() {
        if (this.ˏ == null) {
            synchronized (this) {
                if (this.ˏ == null) {
                    this.ˏ = Collections.unmodifiableMap(ॱ());
                }
            }
        }
        return this.ˏ;
    }

    private Map<String, String> ॱ() {
        Map<String, String> hashMap = new HashMap();
        for (Entry entry : this.ॱ.entrySet()) {
            CharSequence ˏ = ˏ((List) entry.getValue());
            if (!TextUtils.isEmpty(ˏ)) {
                hashMap.put(entry.getKey(), ˏ);
            }
        }
        return hashMap;
    }

    @NonNull
    private String ˏ(@NonNull List<vd> list) {
        StringBuilder stringBuilder = new StringBuilder();
        int size = list.size();
        for (int i = 0; i < size; i++) {
            Object ˏ = ((vd) list.get(i)).ˏ();
            if (!TextUtils.isEmpty(ˏ)) {
                stringBuilder.append(ˏ);
                if (i != list.size() - 1) {
                    stringBuilder.append(',');
                }
            }
        }
        return stringBuilder.toString();
    }

    public String toString() {
        return "LazyHeaders{headers=" + this.ॱ + '}';
    }

    public boolean equals(Object obj) {
        if (!(obj instanceof vm)) {
            return false;
        }
        return this.ॱ.equals(((vm) obj).ॱ);
    }

    public int hashCode() {
        return this.ॱ.hashCode();
    }
}
